<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redis;
use App\Http\Model\Room;
use App\Http\Model\RoomHot;
use App\Http\Model\RoomHeart;
use App\Http\Model\RoomMelee;
use App\Http\Model\RoomTally;
use App\Http\Model\Musics;
use App\Http\Model\RoomHostMicro;
use App\Http\Controllers\RoomController;
use App\Http\Services\RoomHotServices;
use App\Http\Services\GiftServices;
use App\Http\Services\RoomServices;
use App\Http\Model\User;
use App\Http\Model\FinanceUserWallet;
use App\Http\Services\UserServices;

class MakeNewUser extends Command
{
    protected $signature = 'MakeNewUser';

    protected $description = '手工生成用户';

    public function __construct()
    {
        parent::__construct();
    }

    public function handle()
    {
        $phone = 15800000002;//起始的

        $service = new UserServices();

        for($i=0;$i<50;$i++) {
            $usePhone = $phone+$i;
            $password = $this->random_str(10);
            $userId = $service->createUserService($usePhone, $password, 0);
            if ($userId) {
                $service->createWalletService($userId);
            }
            echo $userId." | ".$usePhone." | ".$password." | \r\n";
        }

        return true;   
    }

    function random_str($length) {
        $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
        $str = '';
        for($i = 0; $i < $length; $i++) {
            $str .= substr($chars, mt_rand(0, strlen($chars) - 1), 1);
        }
        return $str;
    }
}